﻿
#include <osgViewer/Viewer>
#include <osgDB/ReadFile>
#include <osgGA/TrackballManipulator>
#include <iostream>

int main()
{
	osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer();
	

	viewer->setUpViewInWindow(100, 100, 800, 600);
	viewer->setSceneData(osgDB::readNodeFile("glider.osg"));
	viewer->setCameraManipulator(new osgGA::TrackballManipulator);
	viewer->realize();

	viewer->setKeyEventSetsDone(osgGA::GUIEventAdapter::KEY_KP_Add); // 小键盘+号键退出
	std::cout << viewer->getThreadingModel() << std::endl; // 输出当前的线程模型

	viewer->setLightingMode(osg::View::SKY_LIGHT);

	if (!osgDB::Registry::instance()->getOptions())
	{
		std::cout << "Option default is null!" << std::endl;
	}

	viewer->run();
	
	// done函数的用法。
	/*
	int framenum = 300;
	while (!viewer->done())
	{
		if (!framenum)
		{
			viewer->setDone(true);
			std::cout << "no need to continue." << std::endl;
		}
		framenum--;
		viewer->frame();
	}
	*/

	return 0;
}